WAFER_DIR := ../../..
WAFER_BUILD_DIR = $(WAFER_DIR)/build
WAFER_FRONTEND := ${WAFER_BUILD_DIR}/bin/wafer-frontend
CLANG := ${WAFER_DIR}/3rdparty/llvm/build/bin/clang++
INCLUDE := /usr/lib/gcc/x86_64-linux-gnu/11/include

sha1.out: sha1.o foo.o
	$(CLANG) $^ \
	-L$(WAFER_BUILD_DIR)/lib/CGRAAPI -lwafer_fpga_api \
	-o $@

sha1.ll: foo.cpp
	${WAFER_FRONTEND} $< -I ${INCLUDE} --lower-crypto-to-fpga --wafer-to-llvmir -o $@

sha1.o: sha1.ll
	$(CLANG) -c $< -o $@

foo.o: foo.cpp
	@${CLANG} -c $< -I ${INCLUDE} -o $@

.PHONY: clean
clean:
	rm -rf *.out *.ll *.mlir *.s *cubin *fatbin *.o *.txt
